package endpoint

import (
	"context"
	"sample/service"

	"github.com/go-kit/kit/endpoint"
)

// Package
// Imports
// Types
// Constants AND Var
// Type Methods

// type Endpoint func(ctx context.Context, request interface{}) (interface{}, error)

type HelloRequest struct {
	Name string `json:"name"`
}

type HelloResponse struct {
	Msg string `json:"msg"`
}

type ByeRequest struct {
	Name string `json:"name"`
}

type ByeResponse struct {
	Msg string `json:"msg"`
}

func MakeHelloEndpoint(s service.IServer) endpoint.Endpoint {
	return func(ctx context.Context, request interface{}) (interface{}, error) {
		req := request.(HelloRequest)
		msg := s.Hello(req.Name)
		return HelloResponse{Msg: msg}, nil
	}
}

func MakeByeEndpoint(s service.IServer) endpoint.Endpoint {
	return func(ctx context.Context, request interface{}) (interface{}, error) {
		req := request.(ByeRequest)
		msg := s.Bye(req.Name)
		return ByeResponse{Msg: msg}, nil
	}
}
